package com.example.myzhugezhaofang.adapter.newhouse;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.mvplibrary.adapter.BaseAdapter;
import com.example.mvplibrary.adapter.BaseViewHolder;
import com.example.myzhugezhaofang.R;
import com.example.myzhugezhaofang.bean.newhouse.CuTenTryTwoBean;

import java.util.List;

public class TryTwoAdapter extends BaseAdapter<CuTenTryTwoBean.DataBean> {
    public onItemListener itemListener;

    public void setListener(onItemListener listener) {
        this.itemListener = listener;
    }

    public TryTwoAdapter(List<CuTenTryTwoBean.DataBean> datas, Context context, int layoutId) {
        super(datas, context, layoutId);
    }

    @Override
    protected void bindData(BaseViewHolder holder, CuTenTryTwoBean.DataBean listBean, int position) {
        TextView text1 = holder.getView(R.id.tv_newhouse_trytwo_1);
        TextView text2 = holder.getView(R.id.tv_newhouse_trytwo_2);
        ImageView image = holder.getView(R.id.iv_newhouse_trytwo);
        /*if (position == 0) {
            image.setBackgroundColor(Color.WHITE);
        }*/
        text1.setText(listBean.getName());
        text2.setText(listBean.getDesc());
        Glide.with(context).load(listBean.getImg_url()).into(image);

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                itemListener.onClick(position);
            }
        });
    }

    public interface onItemListener {
        void onClick(int n);
    }
}
